< previous page page_357 next page >

Page 357
The scheduleReport method is the public interface method that allows a client to specify the name of the report to be printed (argReportName), as well as the date (argReportDate) and time (argReportTime) the report should be printed. The isTimeToPrint method is responsible for comparing the scheduled date and time with the actual date and time within the theTimer_Timer() event. After the scheduled date and time arrive, it invokes the printReport method. The printReport method prints the report as its due date and time arrive. The cancelReport method allows the user to cancel a scheduled report. When canceled, the report is removed from the list box or grid control (either of which acts as a queue of scheduled reports). Listing 16.2 shows the code you could implement for the ReportScheduler class.
LISTING 16.2. CODE YOU COULD IMPLEMENT FOR THEReportSchedulerCLASS METHODS AND EVENTS.

9f8044bafea36a1f728739c0bb58ef4c.gif
 1: Public Function scheduleReport(argReportName As String,  _ argReportDate As Date, argReportTime As Date) As Long
 2: Dim theFlexGrid As theForm.MSFlexGrid1 Static lCount As Long
 3:    lCount = lCount + 1
 4:    'Add another row for the new report
 5:    theFlexGrid.Rows = theFlexGrid.Rows + 1
 6:    'Make the first column of the last row current
 7:    'in order to add data to the cell
 8:    theFlexGrid.Row = theFlexGrid.Rows
 9:    theFlexGrid.Col = 1
10:    theFlexGrid.Text = lCount 'Assign report ID
11:    theFlexGrid.Col = 2
12:    theFlexGrid.Text = argReportName
13:    'Now add data to the remaining columns
14:    theFlexGrid.Col = 3
15:    theFlexGrid.Text = argReportDate
16:    theFlexGrid.Col = 4
17:    theFlexGrid.Text = argReportTime
18:    scheduleReport = lCount
19: End Function
20:
21: Public Sub cancelReport(argReportID As Long)
22:    Dim lRow As Long, lCol As Long
23:    theFlexGrid.Col = 1
24:    For lRow = 1 To theFlexGrid.Rows
25:      theFlexGrid.Row = lRow
26:      If theFlexGrid.Text = argReportID Then
27:         For lCol = 1 To theFlexGrid.Cols
28:           theFlexGrid.Col = lCol
29:           theFlexGrid.Text = 
30:         Next lCol
31:      End If
continues

 
< previous page page_357 next page >

If you like this book, buy it!